/**
 * #############################################################################
 * #
 * 
 * DOCOMO Innovations, Inc.
 * 
 * Copyright © 2011 DOCOMO Innovations, Inc. All rights reserved.
 * 
 * 
 * 
 * Date of Preparation: 08/01/2011
 * 
 * Contact: kozat@docomoinnovations.com
 * 
 * 
 * 
 * All intellectual property rights related to this software are vested in
 * DOCOMO Innovations.
 * 
 * DOCOMO Innovations is under no obligation to maintain or support the
 * software.
 * 
 * Neither DOCOMO Innovations nor its employees are responsible for any damage
 * or loss resulting from the use of the software.
 * 
 * #############################################################################
 * #
 */

package umich.infinity.proxy;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;

public final class Util {
	public static final String notiName(String uid) {
		return Para.CacheRoot + uid + ".noti";
	}
	
	public static final String photoName (String pid) {
		return Para.CacheRoot + pid + ".jpg";
	}
	
	public static final String videoName (String pid) {
		return Para.CacheRoot + pid + ".mp4";
	}
	
	public static final String photoThumbName (String pid) {
		return Para.CacheRoot + pid + "_thumb.jpg";
	}
	
	public static final String friendAlbumName (String uid, String fid) {
		return Para.CacheRoot + "friendAlbum_" + uid + "_" + fid;
	}
	
	public static final String friendListName (String uid) {
		return Para.CacheRoot + "friendList_" + uid;
	}
	
	public static final void myDebug(String tag, String message) {
		System.out.println(tag + ": " + message);
	}
	
	public static final String uploadFileName(String uid, String fileName) {
		return Para.CacheRoot + uid + "/" + fileName;
	}
	
	public static final String uploadFileAttr(String uid, String fileName) {
		return Para.CacheRoot + uid + "/" + fileName + ".attr";
	}
	
	public static final String uploadFileAttr(String path) {
		return Para.CacheRoot + path + ".attr";
	}
	
	public static final String uploadFileData(String uid, String fileName) {
		return Para.CacheRoot + uid + "/" + fileName + ".dat";
	}
	
	public static final String uploadFileData(String path) {
		return Para.CacheRoot + path + ".dat";
	}
	
	public static final String uploadFileMeta(String uid, String fileName) {
		return Para.CacheRoot + uid + "/" + fileName + ".meta";
	}
	
	public static final String uploadFileMeta(String path) {
		return Para.CacheRoot + path + ".meta";
	}
	
	public static final String logFileName(String uid, String fileName) {
		return Para.CacheRoot + Para.CacheLogDir + uid + "/" + fileName;
	}
	
	/**
	 * The counter file stores a counter for uploaded file to avoid collision 
	 * @param uid
	 * @return
	 */	
	public static final String uploadFileCounter(String uid) {
		return Para.CacheRoot + uid + "/counter.dat";
	}
	
	public static String getCurTimeString() {
		Calendar cal = new GregorianCalendar();
		cal.setTimeZone(TimeZone.getTimeZone("GMT"));
		Date date = cal.getTime();
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
		sdf1.setTimeZone(TimeZone.getTimeZone("GMT"));
		SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss");
		sdf2.setTimeZone(TimeZone.getTimeZone("GMT"));
		
		return sdf1.format(date)+"T"+sdf2.format(date)+"+0000";		
	}
}


